<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="com.crm.entity.QuotParts"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<%@page import="com.crm.entity.Opportunity,com.crm.entity.Supplier,java.util.*,com.crm.entity.Quotation" %>
<head>
<link href="<%=application.getContextPath()%>/css/css-crm.css" rel="stylesheet" type="text/css" />



<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery-1.7.2.min.js"></script>
<script language="javaScript" src="<%=application.getContextPath()%>/js/jquery-ui-1.8.20.custom.min.js"></script>
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery-1.6.min.js"></script>	
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery-ui-1.8.17.custom.min.js"></script>	
<link rel="stylesheet" href="<%=application.getContextPath()%>/css/jquery-ui-1.8.17.custom.css"/>
	
<script language="JavaScript" src="<%=application.getContextPath()%>/js/gen_validatorv4.js" type="text/javascript" ></script>
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery.validate.js"></script>	
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery.validate.min.js"></script>	
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />


<link href="<%=application.getContextPath()%>/css/css-crm.css" rel="stylesheet" type="text/css" />


<script type="text/javascript">
function quotclick(){
	var refid=$('#reflistid option:selected').val();
	if((refid==null)||(refid=="")){
		jAlert("Please Select Refrence Number");
		return false;
	}
	else{
	var data="refno="+refid;
	$("#ajaxLoader").show();
	
	$.ajax({
		url:"<%=application.getContextPath()%>/newquot/getquot.do",
		mimetype: "text/html",
		method: "post",
		data:data,
		cache:false,
		success: function(res){
			$('#quotdiv').html(res);
			
			}
		}).done(function(html){
			$("#ajaxLoader").hide();
			/* alert("Ajax Loading Completed"); */
		}).fail(function(html){
			$("#ajaxLoader").hide();
			alert("Failed To Load the Data");
		});
	}
}
    </script>
    
    
</head>
<body>
<%List<Opportunity> opprtlist =(List<Opportunity>)request.getAttribute("opprtunity");%>
<div id="main">
   <%@ include file="common/header.jsp" %>
  <%@ include file="common/submenu.jsp" %>
  <div id="content">
   <div id="resultMsg" class="result_msg">
    <% 
   String msg= request.getParameter("msgsrc");
    String curref= request.getParameter("currentref");
    System.out.println("the current frefrence is"+curref);
    	if(msg!=null){
    		System.out.println(msg);
    		out.println(msg);
    	}
    	 Quotation quot=(Quotation)request.getAttribute("quotobj");
    %>
    </div>
  <form id="impform" name="impform"  action="<%=application.getContextPath()%>/newquot/closeQuot.do"   method="post">
    <div id="work-area2">
      <div class="heading2">Close Quotation</div>
	  
      <div class="boxIFS">
         <table width="100%"  id="validtab" border="0" style="height:80px;"  cellspacing="0" cellpadding="0">
          <tr>
            <td width="700" align="left" valign="middle">
            <table width="700" border="0" cellspacing="0" cellpadding="0">
              <tr><td>&nbsp;</td></tr>
                <tr><td>&nbsp;</td></tr>
              <tr>
                <td align="right"  width=35%" valign="middle">Reference Number </td>
                <td align="center" width="65%" valign="top"><input  class="formbig" type="text" name="refno"  value="<%=quot.getEnqid().getEnqnum()%>"/>
             </td>
              </tr>
              <tr><td>&nbsp;</td></tr>
                <tr>
                <td align="right"  width=35%" valign="middle">Quotation Number </td>
                <td align="center" width="65%" valign="top"><input  class="formbig" type="text"  name="quotno" value="<%=quot.getQuotno()%>"/>
             </td>
              </tr>
                <tr><td>&nbsp;</td></tr>
                <tr>
                <td align="right"  width=35%" valign="middle">Client/CustomerName</td>
                <td align="center" width="65%" valign="top"><input  class="formbig" type="text"  name="client" value="<%=quot.getClientid().getOrganisation()%>"/>
             </td>
              </tr>
                <tr><td>&nbsp;</td></tr>
                <tr>
                <td align="right"  width=35%" valign="middle">Details Of this Quotaions like Compitater offred price etc... </td>
                <td align="center" width="65%" valign="top"><textarea name="desc" style="width: 300px" class="form-textarea" ><%=quot.getClosedesc()%> </textarea>
             </td>
              </tr>
                <tr><td>&nbsp;</td></tr>
                  <tr><td>&nbsp;</td></tr>
        </table>
            
        <table width="100%" border="0" cellpadding="4" cellspacing="1" bgcolor="#C5E4EB">
        <tr>
         
            <td  align="center" valign="middle" background="<%=application.getContextPath() %>/images/table-box.jpg"  style="background-repeat:repeat-x">S.No </td>
            <td  align="center" valign="middle" background="<%=application.getContextPath() %>/images/table-box.jpg"   style="background-repeat:repeat-xbgcolor="#FFFFFF">Part No.</td>
            <td  align="center" valign="middle" background="<%=application.getContextPath() %>/images/table-box.jpg"   style="background-repeat:repeat-xbgcolor="#FFFFFF">Make</td>
            <td  align="center" valign="middle" background="<%=application.getContextPath() %>/images/table-box.jpg"  style="background-repeat:repeat-x bgcolor="#FFFFFF">Description</td>
            <td  align="center" valign="middle" background="<%=application.getContextPath() %>/images/table-box.jpg"   style="background-repeat:repeat-xbgcolor="#FFFFFF">UnitPrice</td>
          <td  align="center" valign="middle" background="<%=application.getContextPath() %>/images/table-box.jpg"   style="background-repeat:repeat-xbgcolor="#FFFFFF">Compitator price</td>
           <td  align="center" valign="middle" background="<%=application.getContextPath() %>/images/table-box.jpg"   style="background-repeat:repeat-xbgcolor="#FFFFFF">Other</td>
          </tr>
          <% 
          Set<QuotParts> setparts= new HashSet<QuotParts>();
        setparts= quot.getQuotParts(); 
        List<QuotParts> listpart=new ArrayList<QuotParts>(setparts);
       // listpart=setparts.iterator();
             
              if(listpart.size()>0)
              {
			for(int i=0;i<listpart.size();i++){ %>
          <tr>
          
            <td align="center" bgcolor="#FFFFFF"><%=i+1 %></td>
           
            <td align="left" valign="top" bgcolor="#FFFFFF"><input name="partno<%=i+1%>" type="text"  size="5" value="<%=listpart.get(i).getPartid().getPrtnum() %>" /></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input name="make<%=i+1 %>" type="text" size="5"   value="<%=listpart.get(i).getMake()%>" /></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input name="desc<%=i+1 %>" type="text" size="5" value="<%=listpart.get(i).getPartid().getDescription()%>"/></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input name="required<%=i+1 %>" type="text" id="reqtyqid<%=i+1 %>" size="5" value="<%=listpart.get(i).getUtprice()%>" /></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input name="cprice<%=i+1 %>" type="text"  size="5" value="<%=listpart.get(i).getOtherparty()%>"/></td>
            <td align="left" valign="top" bgcolor="#FFFFFF"><input name="other<%=i+1 %>" type="text" size="5"  value="<%=listpart.get(i).getOther()%>"/></td>
            <input name="id<%=i+1 %>" id="id<%=i+1 %>" type="hidden" size="5" value="<%=listpart.get(i).getId()%>"/>

          </tr>
      
         <%} 
         }%>
            
        </table>
        
        </td>
         
              <td width="200" align="left" valign="middle">
              <input   type="hidden"  name="EnqId" value="<%=quot.getEnqid().getId()%>"/>
              <input   type="hidden"  name="quotid" value="<%=quot.getId()%>"/>
                 <input   type="hidden"  name="rowcount" value="<%=listpart.size()%>"/>
                 <%System.out.println("the listpart size is"+listpart.size()); %>
            <table width="200" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="left" valign="middle"> <input  class="buttonleft" type="submit"  value="CloseQuotation"/></td>
                <td align="left" valign="middle"></td>
           
              </tr>
             
            </table></td>
          </tr>
        </table>
          
      </div>
      <table style="height:200px; width:910px;" ><tr><td><div id="quotdiv" ></div></td></tr></table> 
    </div>
    </form>
  </div><div id="footer"></div>  
</div>
</body>
<!-- InstanceEnd --></html>

<script language="JavaScript" type="text/javascript">
function processFormData(){
  var frmvalidator  = new Validator("impform");
  
  var rowcount=document.getElementById("rowcountid");
  var rowc=rowcount.value;
//alert("the rowcount value is"+rowc);
  for(var i=1;i<=rowc;i++)
	  {
  frmvalidator.addValidation("partno"+i,"req","Please enter PartNo"+i+"");
  /* frmvalidator.addValidation("partno"+i,"maxlen=30",	"Max length for partno"+i+" is 30");
  frmvalidator.addValidation("partno"+i,"alphanumeric","partno"+i+"Only alpha and Numeric chars only"); */
  
  frmvalidator.addValidation("make"+i,"req","Please enter made by"+i);
 /*  frmvalidator.addValidation("make"+i,"maxlen=30","Max length of made by"+i+"is 30 "); */
  
  frmvalidator.addValidation("required"+i,"req","Please enter Required"+i+" Quantity");
  frmvalidator.addValidation("required"+i,"numeric","Please RequiredQuantity"+i+" must be numeric");
  
  frmvalidator.addValidation("source"+i,"req","source"+i+" must not be empty");
    frmvalidator.addValidation("source"+i,"maxlen=50","maximum  length of source"+i+" is 50");
  /*   frmvalidator.addValidation("source"+i,"alphabetic_space","Source"+i+" must be characters"); */
    
  frmvalidator.addValidation("supplier"+i,"req","supplier"+i+" must not be empty");
/*   frmvalidator.addValidation("supplier"+i,"alphabetic_space"); */
  
  frmvalidator.addValidation("uvalue"+i,"req","unit price must not be empty");
  frmvalidator.addValidation("uvalue"+i,"numeric","Unit value should be number");
  
  frmvalidator.addValidation("fright"+i,"req","fright"+i+" must not be empty");
  frmvalidator.addValidation("fright"+i,"numeric","fright"+i+" value must be numeric");
 
  
  frmvalidator.addValidation("assesable"+i,"req","Assesable"+i+" must not be empty");
  frmvalidator.addValidation("assesable"+i,"numeric","Assesable"+i+" must be numeric");
  
  frmvalidator.addValidation("bcd"+i,"req"," BCD"+i+"must not be empty");
  frmvalidator.addValidation("bcd"+i,"numeric","BCD"+i+" must be numeric");
  
/*   frmvalidator.addValidation("stot"+i,"req","Sub Total"+i+" must not be empty"); */
  frmvalidator.addValidation("stot"+i,"numeric","Sub Total"+i+" must be numeric");
  
  frmvalidator.addValidation("margin"+i,"req","Margin"+i+"must not be empty");
  frmvalidator.addValidation("margin"+i,"numeric","Margin"+i+" must be numeric");
  
  frmvalidator.addValidation("quotprice"+i,"req","Quotation"+i+" price must not be empty");
  frmvalidator.addValidation("quotprice"+i,"numeric","Quotation"+i+" must be numeric");
  
 
	  }
}
</script>